Page({
  data: {
    value: "",
    searchHistory: ["数学公式", "英语单词", "编程教程"],
    hotSearches: ["考研资料", "考公真题", "雅思备考"],
    userInfo: {
      avatarUrl: "/asserts/icon/avatar.png",
      nickName: "用户昵称"
    },
    recommendedCourses: [
      {
        id: 1,
        icon: "/asserts/icon/course1.png",
        name: "Python基础入门课程",
        desc: "从零基础开始学习Python编程",
        url:"https://www.bilibili.com/video/BV1qW4y1a7fU?vd_source=68579557a3a5b41f39a612e1befa2006"
      },
      {
        id: 3,
        icon: "/asserts/icon/高数.png",// 根据实际图标路径修改
        name: "《高等数学》同济版 2024年更新|宋浩老师",
        desc: "宋浩老师讲解的高等数学同济版2024年更新课程",
        url: "https://www.bilibili.com/video/BV1Eb411u7Fw?vd_source=68579557a3a5b41f39a612e1befa2006"
      }
    ],
  },
  onSearchHistoryTap: function (e) {
    const keyword = e.currentTarget.dataset.keyword;
    // 执行搜索逻辑，例如跳转到搜索结果页面
    console.log("点击搜索历史：", keyword);
  },
  onCheckIn: function () {
    // 每日打卡逻辑
    console.log("点击每日打卡");
  },
  onFreeMaterials: function () {
    // 学习成就逻辑
    console.log("点击学习成就");
  },
  onMyPlan: function () {
    // 我的计划逻辑
    console.log("点击我的计划");
  },
  onMyFocus: function () {
    // 开始专注逻辑
    console.log("点击开始专注");
  },
  onCourseTap: function (e) {
    const courseId = e.currentTarget.dataset.id;
    const course = this.data.recommendedCourses.find(c => c.id === courseId);
    if (course && course.url) {
      wx.navigateTo({
        url: `/pages/courseDetail/courseDetail?url=${course.url}`
      });
    } else {
      console.log("课程链接不存在");
    }
  }
});